<template>
  <div class="mod-tenant__tenant">
    <el-form :inline="true" :model="dataForm" @keyup.enter="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.transferTitle" placeholder="移交标题" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.batchNo" placeholder="移交批次" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">{{ $t("query") }}</el-button>
      </el-form-item>
      <div style="width: 103%; height: 15px; background-color: rgb(240, 242, 245); margin: 0 -21px 15px"></div>
      <div style="width: 100%; display: flex; justify-content: space-between">
        <div>
          <el-form-item>
            <el-button @click="getDataList()">接收</el-button>
          </el-form-item>
          <el-form-item>
            <el-button @click="addOrUpdateHandle()">移交</el-button>
          </el-form-item>
        </div>
        <div>
          <el-form-item>
            <el-tag type="success" size="medium"
              >待接收 <span>{{ archiveTransferListStatusVo.toReceiveCount }}</span></el-tag
            >
          </el-form-item>
          <el-form-item>
            <el-tag type="success" size="medium">待审核 {{ archiveTransferListStatusVo.toAuditCount }}</el-tag>
          </el-form-item>
          <el-form-item>
            <el-tag type="success" size="medium">已接收 {{ archiveTransferListStatusVo.alreadyReceivedCount }}</el-tag>
          </el-form-item>
        </div>
      </div>
    </el-form>

    <el-table stripe v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column label="移交批次" prop="batchNo" header-align="center" align="center"></el-table-column>
      <el-table-column label="移交清单标题" prop="transferTitle" header-align="center" align="center"></el-table-column>
      <el-table-column label="档案总数" prop="transferCount" header-align="center" align="center"></el-table-column>
      <el-table-column label="接收公司" prop="transferTenantName" header-align="center" align="center" width="180"></el-table-column>
      <el-table-column label="接收部门" prop="transferDeptName" header-align="center" align="center" width="180"></el-table-column>
      <el-table-column label="移交状态" prop="transferState" header-align="center" align="center">
        <template v-slot="scope">
          <el-tag v-if="scope.row.transferState == 1" size="small" type="success">已接收</el-tag>
          <el-tag v-if="scope.row.transferState == 2" size="small" type="danger">待审核</el-tag>
          <el-tag v-if="scope.row.transferState == 3" size="small" type="danger">待接收</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style="padding: 0px 38%" :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle"> </el-pagination>
    <TransferAdd  v-if="addOrUpdateVisible" ref="addOrUpdate"  @refreshDataList="getDataList"></TransferAdd>
  </div>
</template>

<script lang="ts">
import useView from "@/hooks/useView";
import baseService from "@/service/baseService";
import { defineComponent, reactive, toRefs } from "vue";
import TransferAdd from './transfer-add.vue'

export default defineComponent({
  components:{
    TransferAdd
  },
  setup() {
    const state = reactive({
      getDataListURL: "/archive/transfer-list/page",
      getDataListIsPage: true,
      archiveTransferListStatusVo: {
        toAuditCount: "",
        toReceiveCount: "",
        alreadyReceivedCount: ""
      },
      dataForm: {
        transferTitle: "",
        batchNo: ""
      }
    });

    return { ...useView(state), ...toRefs(state) };
  },
  created() {
    this.getArchiveTransferListStatusVo();
  },
  methods: {
    getArchiveTransferListStatusVo() {
      baseService.get(`/archive/transfer-list/get/status`).then((res) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        }
        console.log(res);
        this.archiveTransferListStatusVo = {
          ...res.data
        };
      });
    }
  }
});
</script>
